package ldh.msg.ui.helper;

import javax.swing.border.TitledBorder;
import javax.swing.border.Border;
import javax.swing.JCheckBox;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Color;

public class CheckBoxTitledBorder extends TitledBorder {
	JCheckBox chkBx = new JCheckBox();
	
	public CheckBoxTitledBorder(String sTitle)	{
		super(" "+ sTitle);
		chkBx.setText(sTitle);
	}
	
	public CheckBoxTitledBorder(String sTitle, boolean bSelect)	{
		super(" "+ sTitle);
		chkBx.setText(sTitle);
		chkBx.setSelected(bSelect);
	}
	
	public CheckBoxTitledBorder(Border border, String sTitle, boolean bSelect)	{
		super(border, " "+ sTitle);
		chkBx.setText(sTitle);
		chkBx.setSelected(bSelect);
	}
	
	public CheckBoxTitledBorder(JCheckBox chkBx, String sTitle, boolean bSelect)	{
		super(" "+ sTitle);
		this.chkBx = chkBx;
		chkBx.setText(sTitle);
		chkBx.setSelected(bSelect);
	}
	
	public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
		super.paintBorder(c,g,x,y,width,height);
		g.setColor(Color.white);
		g.draw3DRect(9, 4, 12, 12, false);
	}

	public boolean isSelected() {
		return chkBx.isSelected();
	}
}